/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 23735
 * Date: 2022-10-22
 * Time: 21:55
 */
class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    TreeNode() {}
    TreeNode(int val) { this.val = val; }
    TreeNode(int val, TreeNode left, TreeNode right) {
        this.val = val;
        this.left = left;
        this.right = right;
    }
}
class Solution {
    public TreeNode cur;
    public TreeNode head;
    public void inOrder(TreeNode root){
        if(root==null){
            return ;
        }
        inOrder(root.left);
        if(this.head==null){
            this.head=root;
        }
        cur.right=root;
        cur=root;
        cur.left=null;
        inOrder(root.right);
    }
    public TreeNode increasingBST(TreeNode root) {
        this.cur=new TreeNode(-1);
        inOrder(root);
        return this.head;
    }
}
